//
//  BDUserAddressModel.m
//  BadBoy
//
//  Created by wen on 2017/4/21.
//  Copyright © 2017年 com.8xiong. All rights reserved.
//

#import "BDUserAddressModel.h"
#import "BDCityInfo.h"

@implementation BDUserAddressModel

+ (NSDictionary *)mj_replacedKeyFromPropertyName{
    return @{@"address_id":@"id",
             @"isDefault":@"default"};
}

- (NSString *)cityStr{
    if (self.province_id != 0 && self.city_id != 0 && self.district_id != 0) {
        _cityStr = @"";
        NSArray *arr = @[@(self.province_id),@(self.city_id),@(self.district_id)];
        NSMutableArray *infoArray = [NSMutableArray array];
        for (int i = 0; i < arr.count; i++) {
            BDCityInfo *cityInfo = [BDCityInfo getCityWithId:[arr[i] integerValue]];
            [infoArray addObject:cityInfo];
            if (i == 1) {
                BDCityInfo *firCityInfo = infoArray.firstObject;
                if ([firCityInfo.name isEqualToString:cityInfo.name]) {
                    continue;
                }
            }
            _cityStr = [_cityStr stringByAppendingString:cityInfo.name];
        }
        return _cityStr;
    }
    return @"";
}

@end
